﻿
@{
    ViewBag.Title = "新闻发布";
}
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<meta name="format-detection" content="telephone=no">
<meta name="msapplication-tap-highlight" content="no">
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
<div class="title-content">新闻发布</div>
<div>
    <script src="~/Scripts/upLoadFile/upLoadFile.js"></script>
    <link href="~/Scripts/ueditor/themes/default/css/ueditor.css" rel="stylesheet" />
    <script src="~/Scripts/ueditor/third-party/jquery-1.10.2.js"></script>
    <script type="text/javascript" charset="utf-8" src="~/Scripts/ueditor/ueditor.config.js"></script>
    @*<script src="~/Scripts/ueditor/lang/zh-cn/zh-cn.js"></script>*@
    <script type="text/javascript" charset="utf-8" src="~/Scripts/ueditor/ueditor.all.min.js"></script>
    <div class="form-group">
        <input class="form-control form-control-solid placeholder-no-fix" type="text" placeholder="新闻标题" id="title" style="width:400px;" />
    </div>
    <div class="form-group">
        <input class="form-control form-control-solid placeholder-no-fix" type="text" placeholder="新闻来源" id="source" style="width:400px;" />
    </div>
    <div class="form-group">
        <img id="imgsourse" src="" style="width:40px;height:40px;" /><a href="#addsource" style="margin-left:30px;" data-toggle="modal" class="btn sbold green">上传图片标题</a>
    </div>
    <div>
        <!--style给定宽度可以影响编辑器的最终宽度-->
        <script type="text/plain" id="myEditor" style="width:100%;height:370px;"></script>
        <div style="margin-top:10px;text-align:center;width:100%;">
            <button type="button" class="btn green" onclick="save()">保存</button>
        </div>
    </div>


    <!-- 弹出层，上传图片-->
    <div id="addsource" class="modal fade" tabindex="-1" data-focus-on="input:first" data-width="600">
        <div class="modal-content" style="height:400px;">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
                <h4 id="editTitle" class="modal-title">上传图片来源</h4>
            </div>
            <div class="modal-body">
                <div style="margin-left:10px;">
                    <div>
                        <input type="file" value="" id="fileInput" name="files" onchange="fileSelected()" />
                        <div style="margin:30px;">
                            <input type="button" value="上传" onclick="uploadFile('news')" />
                        </div>
                        <div style="margin:30px;">
                            <div id="fileName"></div>
                            <div id="fileSize"></div>
                            <div id="fileType"></div>
                        </div>
                        <div style="margin:30px;width:500px;height:15px;border:1px solid #aeaeae;">
                            <div id="progress" style="background:#4cff00;height:15px;width:0%;"></div>
                            <div id="percentNumber"></div>
                        </div>
                        <div style="margin:30px;">
                            <div id="msg"></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>


   
    <script type="text/javascript">
       
        window.UEDITOR_HOME_URL = "/Scripts/ueditor/";
        var um = UE.getEditor('myEditor', {
            toolbars: [[
                'fullscreen', 'source', '|', 'undo', 'redo', '|',
                'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc', '|',
                'rowspacingtop', 'rowspacingbottom', 'lineheight', '|',
                'customstyle', 'paragraph', 'fontfamily', 'fontsize', '|',
                'directionalityltr', 'directionalityrtl', 'indent', '|',
                'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|', 'touppercase', 'tolowercase', '|',
                'link', 'unlink', 'anchor', '|', 'imagenone', 'imageleft', 'imageright', 'imagecenter', '|',
                'simpleupload'
            ]]
        });//, 'insertimage'
        function save() {
            var html = UE.getEditor('myEditor').getContent();
            //var contentBM = encodeURIComponent(html); //encodeURI(html);// decodeURI(html);
            var str = CryptoJS.enc.Utf8.parse(html);
            var contentBM = CryptoJS.enc.Base64.stringify(str);
            //var contentBM = encodeURI(html);
            var news = {
                title: $("#title").val(),
                contentWZ: contentBM,
                source: $("#source").val(),
                headImgURL: $("#imgsourse").attr("src")
            };
            AjaxCustom({
                url: "/NewsPublish/InsertPublish",
                type: "post",
                parames: news,
                callBack: function (data) {
                    if (data.code == "1") {
                        AlertMsg("保存成功");
                    }
                }
            });
        }

        window.onload = function () {
            $("#title").focus();
            //UM.getEditor('myEditor').focus(); //编辑器获得焦点
        }
    </script>
</div>

